package org.example.microservice.basedata.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.microservice.basedata.mapper.VehicleMapper;
import org.example.microservice.basedata.model.dto.VehicleDto;
import org.example.microservice.basedata.model.po.Vehicle;
import org.example.microservice.basedata.service.VehicleService;
import org.example.microservice.sys.api.feign.DepartmentFeign;
import org.example.microservice.sys.api.vo.Department;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 基础数据-车辆信息表 服务实现类
 * </p>
 *
 * @author CGG
 * @since 2024-04-23
 */
@Service
public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> implements VehicleService {

    @Resource
    private DepartmentFeign departmentFeign;

    @Override
    public VehicleDto getVehicleInfo(Long id) {
        VehicleDto vehicleDto = baseMapper.getVehicleInfo(id);
        if (vehicleDto.getBelongDepartment() != null) {
            Department department = departmentFeign.getDepartment(vehicleDto.getBelongDepartment());
            vehicleDto.setBelongDepartmentName(department.getName());
        }
        return vehicleDto;
    }
}
